<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ page   import="grupobbva.pe.operhc.domain.SegUsuario"%>
<%@ page   import="java.util.List"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/ui.jqgrid.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/redmond/jquery-ui-1.8.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/operhc_style.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath()%>/css/buttonOHC.css" />

<script type="text/javascript" src='<%= request.getContextPath()%>/dwr/interface/LogCargaDataAction.js'></script>
<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/engine.js'></script>
<script type='text/javascript' src='<%= request.getContextPath()%>/dwr/util.js'></script>
<script src="<%=request.getContextPath()%>/js/util/gridUtil.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/jquery-1.7.1.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/i18n/grid.locale-es.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/jquery.jqGrid.src.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/grid.subgrid.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/util/encabezado.js" type="text/javascript"></script>

<script type="text/javascript" charset="UTF-8">

var rutaContexto1 = location.pathname;
var rutaContexto2 = "<%=request.getContextPath()%>";
var rutaContexto  = rutaContexto1.substr(0, rutaContexto1.indexOf(rutaContexto2)) + rutaContexto2;

<%
SegUsuario usuarioSession = (SegUsuario)request.getSession().getAttribute("usuarioSession");
if(!"1".equals(usuarioSession.getAdmin())){ 
response.sendRedirect("operativizacion.jsp");
}%>

var myColNames  = ['','Id', 'Fecha Creacion', 'Nombre Archivo',' Descripcion', 'Tipo'];
var myDataModel = [ {name : 'codigo',										width : VAL_WIDTH.VSMALL, hidden : true	},
                    {name : 'codigo',				index : 'codigo', 			width : VAL_WIDTH.VSMALL				 },
                    {name : 'fechaCreacion',	index : 'fechaCreacion',width : VAL_WIDTH.SMALL					},
                    {name : 'nombreArchivo',	index : 'nombreArchivo',width : VAL_WIDTH.MED					},
                    {name : 'descripcion',		index : 'descripcion',	width : VAL_WIDTH.BMED					},
                    {name : 'tipoCarga',		index : 'tipoCarga', 	width : VAL_WIDTH.XSMALL				}                               
                   ];
                   
function consultar(){

	jQuery("#listLogCarga").GridUnload();
	
	LogCargaDataAction.consultarAjax(function(data){
		
		mostrarTabla(data);
	});
}

function mostrarTabla(data){
	
	$('body').append('<div id="paginador_listLogCarga" class="grid"></div>'); 
	var paginador = "paginador_listLogCarga";
	
	jQuery("#listLogCarga").jqGrid(
	{
		beforeSelectRow: function(){},
		caption		: "Listado de Log de Carga",
		data 	 	: data,
		datatype 	: "local",
		height   	: "100%",
		weight 	 	: 1000,
		colNames 	: myColNames,
		colModel 	: myDataModel,
		rowList 	: [5,10,15,20,25],
		rowNum 		: 15, 
		pager 		: paginador,
		viewrecords : true,
		multiselect : true,			
		subGrid    	: false,
		footerrow  	: false,
		loadComplete :
           function (data) {}
	});
}

function validacionForm(operacion){
	
	var formulario = document.getElementById('formLogCargaList');
	if(operacion == 'cancelar'){
	
		formulario.action = rutaContexto+'/adminForm.do?method=verMantenimiento';
		formulario.submit();
	}else if(operacion == 'eliminar'){
		
		var selecciones = buscarSelecciones("listLogCarga");
		if (selecciones.length == 0){
			alert('No ha seleccionado ningún elemento para la eliminación.');
			return false;
		}		
		
		var ans = confirm('¿Esta seguro que desea eliminar los registros seleccionados?');
		if(ans){
			
			formulario.seleccionados.value = selecciones;
			formulario.action = rutaContexto+'/mantenimientoLogCargaData.do?method=eliminar';
			formulario.submit();
		}			
	}
}

</script>
</head>
<body onload="consultar();">

<html:form method="post" styleId="formLogCargaList" action="mantenimientoLogCargaData.do?method=verListado">
<html:hidden property="seleccionados" styleId="seleccionados"/>

	<div style="background-color: #0066bb;">
		<font face="Arial Narrow" size=3 color="#FFFFFF"><b>&nbsp;<bean:message key="etiqueta.titleManteLogCarga"/></b></font>
	</div>
	
	<center>
	<%
	Object messageError = request.getAttribute("messageError");
	if(messageError != null){
		if(messageError instanceof List){
			
			List listMsg = (List)messageError;
			if(!listMsg.isEmpty()){%>
				
				<div class="error">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageError)){%>
				
				<div class="error">
			    	<img alt="" src="images/icono_error.png" width="17px" height="17px" class="icon">
			    	<%=messageError%><br/>
			    </div>				
			<%}
		}
	}
	%>
	

	<%
	Object messageInfo = request.getAttribute("messageInfo");
	if(messageInfo != null){
		if(messageInfo instanceof List){
			
			List listMsg = (List)messageInfo;
			if(!listMsg.isEmpty()){%>
				
				<div class="message">
					<% 
					for(int i = 0; i < listMsg.size(); i++){%>
						<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    		<%=listMsg.get(i)%><br/>
					<%}
					%>	
				</div>
			<%}			
			
		}else{
			if(!"".equals(messageInfo)){%>
				
				<div class="message">
			    	<img alt="" src="images/information-icon.png" width="17px" height="17px" class="icon">
			    	<%=messageInfo%><br/>
			    </div>				
			<%}
		}
	}
	%>
	</center>
	
	<table align="center">
	<tr>
	
	<td align="right" valign="middle">
		Archivo:
	</td>
	
	<td align="left" valign="middle">
			 <html:select property="idArchivoCarga" >
				<html:option value="0">SELECCIONAR</html:option>										
				<html:optionsCollection name="LogCargaDataForm" property="archivoCargaList" label="label" value="valor" />										
			</html:select>
	</td>
	
	</tr>
	</table><br/>
	
	<br/>
	<table width="100%">

		<tr>
		<td  align="center" valign="middle">
			<a href="#" onclick="validacionForm('eliminar');" class="buttonOHC">ELIMINAR</a>&nbsp;&nbsp;
			<a href="#" onclick="validacionForm('cancelar');" class="buttonOHC">REGRESAR</a>			
		</td>
		</tr>
	</table>
	<p></p>
	<center>
	<table id="listLogCarga" class="grid">
	</table>
	</center>
	

</html:form>
</body>
</html>